# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
require "rutils"
require "common"
require "hpricot"

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  include SimpleCaptcha::ControllerHelpers
  helper :all # include all helpers, all the time
  RuTils::overrides = true
  ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
          :day => "%d",
          :month => "%m",
          :year => "%y",
          :time => "%H:%M",
          :little => "%d.%m.%Y %H:%M",
          :mini => "%d.%m %H:%M"
        )

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => 'df796998e9b9019058b3aeb9f2374b09'
  
  # See ActionController::Base for details 
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password"). 
  filter_parameter_logging :password
  
  private
  
  def local_request?
	  false if RAILS_ENV == 'production'
	end

  def rescue_action_in_public(exception)
    case exception
      when ::ActionController::RoutingError, ::ActionController::UnknownAction, ::ActiveRecord::RecordNotFound
        render :file=>"#{RAILS_ROOT}/public/404.html", :layout=>false, :status=>404
      else
      	super
    end
  end
end
